import { FC, useState, useEffect, useRef } from 'react';
import {
  Divider,
  Space,
  Table,
  Button,
  message,
  Spin,
  Pagination,
  Form,
  Input,
  Select,
} from 'antd';
import './detail.less';
import { useLocation } from 'react-router-dom';
import { getUrlParams } from '@src/utils';
import { getSmallPolicyByOrderNoApi } from '@src/apis/invoiceApis';
export const ProductConfigurationAdd: FC = () => {
  const { Option } = Select;
  const { TextArea } = Input;

  const [form] = Form.useForm();
  const location = useLocation();
  const localtions: any = useLocation();
  const searchObj: any = getUrlParams(localtions.search);
  // useEffect(() => {
  //   getPageInfo();
  //   return () => {};
  // }, [location]);

  const [loading, setLoading] = useState<boolean>(false);
  const [pageData, setPageData] = useState<any>({
    subPolicyDetail: { riskInfoDTOList: [] },
    proposalDetail: {},
  });
  const getPageInfo = () => {
    setLoading(true);
    getSmallPolicyByOrderNoApi({
      orderNo: searchObj.orderNo,
    })
      .then((result: any) => {
        setLoading(false);
        result.data.subPolicyDetail.riskInfoDTOList?.forEach((item: any) => {
          item.chinaName = JSON.parse(item.chinaName || '[]');
        });
        setPageData(result.data);
      })
      .catch((err: any) => {
        console.log(err);
        setLoading(false);
      });
  };
  const submitF = () => {};
  const saveF = () => {
    console.log('暂存函数');
    form.validateFields().then((values: any) => {
      console.log(values);
    });
  };
  return (
    <Spin spinning={loading} delay={100}>
      <div className="pageBox pad20 fff addConfiguration">
        <Form layout="inline" className="addForm" form={form} name="userInfoForm">
          <div className="publicH1Box">
            <h1>承保默认信息</h1>
            <div className="itemBox">
              <Form.Item label="业务类型名称" name="业务类型名称">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="渠道代码" name="渠道代码">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="出单子账号" name="出单子账号">
                <Input placeholder="请输入" />
              </Form.Item>
            </div>
          </div>
          <div className="publicH1Box margT20">
            <h1>公共信息</h1>
            <div className="itemBox">
              <Form.Item label="业务来源" name="业务来源">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="系统来源" name="系统来源">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="争议解决方式" name="争议解决方式">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="司法管辖" name="司法管辖">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="保单币别" name="保单币别">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="缴费方式" name="缴费方式">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="录单员名称" name="录单员名称">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="录单机构" name="录单机构">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="归属业务员代码" name="归属业务员代码">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="归属业务员名称" name="归属业务员名称">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="归属业务机构" name="归属业务机构">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="见费出单标识" name="见费出单标识">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="仲裁委员会名称" name="仲裁委员会名称">
                <Input placeholder="请输入" />
              </Form.Item>
            </div>
          </div>
          <div className="publicH1Box margT20">
            <h1>投被保人大保单默认信息</h1>
            <div className="itemBox">
              <Form.Item label="投保人名称" name="投保人名称">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="投保人类型" name="投保人类型">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="投保人证件类型" name="投保人证件类型">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="投保人证件号码" name="投保人证件号码">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="被保人名称" name="被保人名称">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="被保人类型" name="被保人类型">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="被保人证件类型" name="被保人证件类型">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="被保人证件号码" name="被保人证件号码">
                <Input placeholder="请输入" />
              </Form.Item>
            </div>
          </div>
          <div className="publicH1Box margT20">
            <h1>销售信息</h1>
            <div className="itemBox">
              <Form.Item label="代理人代码" name="代理人代码">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="代理人名称" name="代理人名称">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="渠道大类" name="渠道大类">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="渠道细分" name="渠道细分">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
            </div>
          </div>
          <div className="publicH1Box margT20">
            <h1>核保信息</h1>
            <div className="itemBox">
              <Form.Item label="是否体内收/退费(投保)" name="是否体内收/退费（投保）">
                <Select allowClear placeholder="请选择">
                  <Option value={1}>asdf</Option>
                </Select>
              </Form.Item>
              <Form.Item label="是否体内收/退费(批改)" name="是否体内收/退费（批改）">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="核保人员代码" name="核保人员代码">
                <Input placeholder="请输入" />
              </Form.Item>
              <Form.Item label="核保人员名称" name="核保人员名称">
                <Input placeholder="请输入" />
              </Form.Item>
            </div>
          </div>
          <div className="publicH1Box margT20">
            <h1>邮箱配置</h1>
            <div className="itemBox" style={{ paddingBottom: '40px' }}>
              <Form.Item label="邮件主送" name="邮件主送">
                <TextArea autoSize={{ minRows: 3, maxRows: 3 }} placeholder="请输入" allowClear />
              </Form.Item>
              <Form.Item label="邮件抄送" name="邮件抄送">
                <TextArea autoSize={{ minRows: 3, maxRows: 3 }} placeholder="请输入" allowClear />
              </Form.Item>
            </div>
          </div>

          <div className="formBtns">
            <Button>取消</Button>
            <Button className="marg020" type="primary" onClick={saveF}>
              暂存
            </Button>
            <Button type="primary" onClick={submitF}>
              提交
            </Button>
          </div>
        </Form>
      </div>
    </Spin>
  );
};
